﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MainCamCtr : MonoBehaviour {

    Vector3 start_pos;
    Color start_color;
    float start_fieldOfView;
    Camera _cam;
    bool onDebugMode;

	void Start () {
        start_pos = transform.position;
        _cam = GetComponentInChildren<Camera>();
        start_color = _cam.backgroundColor;
        start_fieldOfView = _cam.fieldOfView;
    }
	
	void Update () {
        PackageData packageData = AppDataManager.Instance.GetCurrentPackageInfo();
        if (packageData != null)
        {
            PackageConfig packageConfig = packageData.packageConfig;
            transform.position = start_pos + new Vector3(packageConfig.camera_offsetX, packageConfig.camera_offsetY, 0);
            _cam.fieldOfView = packageConfig.totalscaling_tolerance * start_fieldOfView;
        }

        if (Input.GetKeyDown(KeyCode.D))
        {
            onDebugMode = !onDebugMode;
            _cam.backgroundColor = onDebugMode ? new Color(0.3f, 0.3f, 0.3f) : start_color;
        }
	}
}
